<template>
  <div>
    <div id="add_container">
      <p>添加账号</p>
      <div class="add_container_form">
        <div class="add_form_name">
          <span>账号</span>
          <el-input v-model="username" style="width: 250px"></el-input>
        </div>
        <div class="add_form_pwd">
          <span>密码</span>
          <el-input v-model="userpwd" style="width: 250px"></el-input>
        </div>

        <div class="add_form_team">
          <span>用户组</span>
          <el-select v-model="userteam" style="width: 250px">
            <el-option label="超级管理员" value="超级管理员"> </el-option>
            <el-option label="普通管理员" value="普通管理员"> </el-option>
          </el-select>
        </div>

        <div class="add_btn">
          <el-button @click="useradd" type="primary">添加</el-button>
          <el-button>重置</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { adduser } from "@/apis/users";
export default {
  data() {
    return {
      username: "",
      userpwd: "",
      userteam: "普通管理员",
    };
  },
  methods: {
    //点击添加账号
    useradd() {
      adduser({
        account: this.username,
        password: this.userpwd,
        userGroup: this.userteam,
      }).then((res) => {
        console.log(res.data.msg);
        this.$message({
          message: "添加成功",
          type: "success",
        });
      });
    },
  },
};
</script>

<style lang="less" scoped>
#add_container {
  background-color: #fff;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  p {
    line-height: 50px;
    border-bottom: 1px solid #f4f5f9;
    padding: 0 20px;
    color: #848485;
    margin-bottom: 20px;
  }
  .add_container_form {
    width: 350px;
    margin-left: 30px;
    .add_form_name,
    .add_form_pwd,
    .add_form_team {
      display: flex;
      align-items: center;
      margin-bottom: 10px;
      span {
        flex: 1;
        text-align: right;
        margin-right: 10px;
      }
    }
    .add_btn {
      display: flex;
      justify-content: center;
      padding-bottom: 20px;
    }
  }
}
</style>